package com.info.provider.auth;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Component;

/**
 * Created by ps_se on 2017/5/29 13:58.
 * Description:
 * Modified By:
 * Version:
 *
 * @author pengshuo
 */
@Component
public class CustomerUserDetailsService implements UserDetailsService{

    @Value("${auth.info.username}")
    private String username;

    @Value("${auth.info.password}")
    private String password;

    @Value("${auth.info.role}")
    private String role;

    /**
     * @param auth
     * @return
     * @throws UsernameNotFoundException
     */
    @Override
    public UserDetails loadUserByUsername(String auth) throws UsernameNotFoundException {
        if(username.equals(auth)){
            return new SecurityUser(username,password,role);
        }
        return null;
    }
}
